const { postInfo, getUserInfo } = require("../service/ice/user");
const { getVcode, checkVcode } = require("../service/user/login");
const { mpLogin, bindMobile } = require("../service/user/mp-login");

const app = require("express").Router();

app.all("/mp-login", async (req, res) => {
  const data = await mpLogin(req._body, req.realIp);
  res.send(data);
});

app.all("/auth/bind-mobile", async (req, res) => {
  const data = await bindMobile(req._body, req.user.id);
  res.send(data);
});

app.get("/vcode", async (req, res) => {
  const data = await getVcode(req.query, req.user?.id, req.realIp);
  res.send(data);
});

app.all("/check-vcode", async (req, res) => {
  const data = await checkVcode(req._body, req.realIp);
  res.send(data);
});

app.get("/auth/user-info", async (req, res) => {
  const data = await getUserInfo(req.query, req.user.id);
  res.send(data);
});

app.post("/auth/user-info", async (req, res) => {
  const data = await postInfo(req.body, req.user.id);
  res.send(data);
});

module.exports = app;
